﻿using System;
using System.Configuration;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.Samples.Office.UnifiedCommunications.Gadget.Config
{
    public class FavoriteElement : ConfigurationElement
    {
        #region Constructors

        static FavoriteElement()
        {
            s_orderKey = new ConfigurationProperty("orderKey", typeof(int), null, ConfigurationPropertyOptions.IsKey);
            s_contactID = new ConfigurationProperty("contactID", typeof(string), null, ConfigurationPropertyOptions.IsRequired);
            s_displayName = new ConfigurationProperty("displayName", typeof(string), null, ConfigurationPropertyOptions.None);
            s_defaultClickAction = new ConfigurationProperty("defaultClickAction", typeof(string), null, ConfigurationPropertyOptions.None);
            s_isPhoneNumber = new ConfigurationProperty("isPhoneNumber", typeof(bool), null, ConfigurationPropertyOptions.None);

            s_properties = new ConfigurationPropertyCollection();

            s_properties.Add(s_orderKey);
            s_properties.Add(s_contactID);
            s_properties.Add(s_displayName);
            s_properties.Add(s_defaultClickAction);
            s_properties.Add(s_isPhoneNumber);
        }

        #endregion

        #region Static Fields
        private static ConfigurationProperty s_orderKey;
        private static ConfigurationProperty s_contactID;
        private static ConfigurationProperty s_displayName;
        private static ConfigurationProperty s_defaultClickAction;
        private static ConfigurationProperty s_isPhoneNumber;

        private static ConfigurationPropertyCollection s_properties;
        #endregion

        #region Properties

        [ConfigurationProperty("orderKey", IsKey=true, IsRequired = true)]
        public int OrderKey
        {
            get { return (int)base[s_orderKey]; }
            set { base[s_orderKey] = value; }
        }

        [ConfigurationProperty("contactID", IsRequired = true)]
        public string ContactID
        {
            get { return (string)base[s_contactID]; }
            set { base[s_contactID] = value; }
        }

        [ConfigurationProperty("displayName", IsRequired = false)]
        public string DisplayName
        {
            get { return (string)base[s_displayName]; }
            set { base[s_displayName] = value; }
        }

        [ConfigurationProperty("defaultClickAction", IsRequired = false)]
        public string DefaultClickAction
        {
            get { return (string)base[s_defaultClickAction]; }
            set { base[s_defaultClickAction] = value; }
        }

        [ConfigurationProperty("isPhoneNumber", IsRequired = false)]
        public bool IsPhoneNumber
        {
            get { return (bool)base[s_isPhoneNumber]; }
            set { base[s_isPhoneNumber] = value; }
        }

        protected override ConfigurationPropertyCollection Properties
        {
            get { return s_properties; }
        }

        #endregion
    }
}
